<template>
  <view class="hot-activities">
    <view class="section-header">
      <text class="section-title">热门活动</text>
      <view class="activity-tag">活动</view>
      <text class="view-more" @click="$emit('view-more')">查看更多 ></text>
    </view>
    <view class="section-subtitle">618大促,满300减30</view>
    <scroll-view class="product-scroll" scroll-x="true">
      <view class="product-item" v-for="(item, index) in products" :key="index" @click="$emit('product-click', {id: index, name: item.name})">
        <image class="product-image" :src="item.image" mode="aspectFill"></image>
        <text class="product-price">¥{{item.price}}</text>
      </view>
    </scroll-view>
  </view>
</template>

<script>
export default {
  name: 'HotActivities',
  props: {
    products: {
      type: Array,
      required: true
    }
  },
  emits: ['view-more', 'product-click']
};
</script>

<style scoped lang="scss">
@import "../../../static/common.scss";

.hot-activities {
  background-color: #fff;
  margin: 0 30rpx 20rpx;
  border-radius: 20rpx;
  padding: 30rpx;
}

.section-header {
  @include flex-between;
  align-items: center;
  margin-bottom: 15rpx;
}

.section-title {
  font-size: 32rpx;
  font-weight: bold;
  color: #333;
}

.activity-tag {
  background-color: #ff4757;
  color: white;
  padding: 4rpx 12rpx;
  border-radius: 12rpx;
  font-size: 20rpx;
  margin-left: 15rpx;
}

.view-more {
  color: #666;
  font-size: 24rpx;
}

.section-subtitle {
  color: #666;
  font-size: 26rpx;
  margin-bottom: 20rpx;
}

.product-scroll {
  white-space: nowrap;
}

.product-item {
  display: inline-block;
  margin-right: 20rpx;
  text-align: center;
}

.product-item .product-image {
  width: 120rpx;
  height: 120rpx;
  border-radius: 15rpx;
  margin-bottom: 10rpx;
}

.product-price {
  color: #ff4757;
  font-size: 26rpx;
  font-weight: bold;
}
</style>